#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
path=$(dirname $PWD/$0)
echo --- install docker start ---
yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2
yum-config-manager \
    --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

yum install -y docker-ce docker-ce-cli containerd.io
echo --- install docker end ---

echo --- install docker-compose start ---
cp  $path/docker-compose/v2.2.2 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose -v
systemctl start docker
systemctl enable docker
echo --- install docker-compose end ---

echo --- install git start ---
yum install -y curl-devel expat-devel gettext-devel \
  openssl-devel zlib-devel git-core
echo --- install git end ---

echo --- 配置镜像加速器 start ---
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://96c2586v.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
echo --- 配置镜像加速器 end ---

echo --- docker init start ---
# docker login --username=591713832@qq.com registry.cn-zhangjiakou.aliyuncs.com
docker-compose -f $path/../docker/docker-compose.yml up -d
echo --- docker init start ---


echo --- code updata start ---
docker_path=/www/wwwroot/hkv2
docker exec -w $docker_path btlnp git reset HEAD --hard
docker exec -w $docker_path btlnp git pull
echo --- code updata  start ---
